package com.googlecode.stockhamster.client.swing;

import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.net.MalformedURLException;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class SwingClient extends JFrame {
	private static final long serialVersionUID = -1476963292916032143L;

	public JPanel contentPanel;
	public ArbiterPanel arbiterPanel;
	public BankPanel bankPanel;
	public CompanyPanel companyPanel;
	public RumorPanel rumorPanel;
	public StockStatPanel stockStatPanel;
	public CardLayout card;
	
	public SwingClient() throws MalformedURLException {
		setLayout(new BorderLayout());
		JPanel buttonPanel = new JPanel();
		contentPanel = new JPanel();
		add(buttonPanel, BorderLayout.NORTH);
		add(contentPanel, BorderLayout.CENTER);
		
		arbiterPanel = new ArbiterPanel();
		bankPanel = new BankPanel();
		companyPanel = new CompanyPanel();
		rumorPanel = new RumorPanel();
		stockStatPanel = new StockStatPanel();
		card = new CardLayout();
		contentPanel.setLayout(card);
		contentPanel.add(arbiterPanel, "arbiter");
		contentPanel.add(bankPanel, "bank");
		contentPanel.add(companyPanel, "company");
		contentPanel.add(rumorPanel, "rumor");
		contentPanel.add(stockStatPanel, "stockstat");
		
		JButton button = new JButton("Arbiter");
		button.addActionListener(new SwapListener(this, "arbiter"));
		buttonPanel.add(button);
		button = new JButton("Bank");
		button.addActionListener(new SwapListener(this, "bank"));
		buttonPanel.add(button);
		button = new JButton("Company");
		button.addActionListener(new SwapListener(this, "company"));
		buttonPanel.add(button);
		button = new JButton("Rumor");
		button.addActionListener(new SwapListener(this, "rumor"));
		buttonPanel.add(button);
		button = new JButton("StockStat");
		button.addActionListener(new SwapListener(this, "stockstat"));
		buttonPanel.add(button);
		
		setSize(800, 550);
		addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {
				System.exit(0);
			}
		});
	}
	
	public static void main(String[] args) throws MalformedURLException {
		new SwingClient().setVisible(true);
	}

}
